from django.contrib import admin
from .models import AIProvider, Scene, Mailbox, EmailMessage, ExtractionRun, ExtractionResult, Shipment

@admin.register(AIProvider)
class AIProviderAdmin(admin.ModelAdmin):
    list_display = ("name", "base_url", "enabled", "timeout_seconds")
    search_fields = ("name",)

@admin.register(Scene)
class SceneAdmin(admin.ModelAdmin):
    list_display = ("name", "email_type", "enabled", "priority", "ai_provider")
    list_filter = ("enabled",)
    search_fields = ("name", "email_type")

@admin.register(Mailbox)
class MailboxAdmin(admin.ModelAdmin):
    list_display = ("name", "host", "username", "folder", "enabled")
    list_filter = ("enabled",)
    search_fields = ("name", "username")

@admin.register(EmailMessage)
class EmailMessageAdmin(admin.ModelAdmin):
    list_display = ("message_id", "subject", "from_addr", "date", "created_at")
    search_fields = ("message_id", "subject", "from_addr")

@admin.register(ExtractionRun)
class ExtractionRunAdmin(admin.ModelAdmin):
    list_display = ("id", "scene", "mailbox", "email", "status", "started_at", "finished_at")
    list_filter = ("status", "scene")

@admin.register(ExtractionResult)
class ExtractionResultAdmin(admin.ModelAdmin):
    list_display = ("run", "field", "value", "confidence", "source")
    list_filter = ("source",)

@admin.register(Shipment)
class ShipmentAdmin(admin.ModelAdmin):
    list_display = ("po_no", "booking_no", "bl_no", "vessel", "voyage", "pol", "pod", "updated_at")
    search_fields = ("po_no", "booking_no", "bl_no", "container_no")
